package cn.car.service.remote.process.Impl;

import cn.car.biz.carAccess.cache.AccessTokenCache;
import cn.car.domains.dto.AccessTokenDto;
import cn.car.domains.dto.BaseResponse;
import cn.car.domains.info.AccessTokenInfo;
import cn.car.service.config.SystemConfig;
import cn.car.service.remote.process.Processor;
import cn.hutool.core.bean.BeanUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service("accessTokenProcessor")
public class AccessTokenProcessor implements Processor {

    @Resource
    private AccessTokenCache cache;

    @Resource
    private SystemConfig systemConfig;
    @Override
    public void process(BaseResponse response) {

        //把accessToken放入缓存
        AccessTokenDto accessTokenDto = (AccessTokenDto) response;
        AccessTokenInfo bean = BeanUtil.toBean(accessTokenDto, AccessTokenInfo.class);
        cache.put(systemConfig.getCompanyCode().get(), bean);
    }
}
